package com.sgb.kjwl.view.ui.activity.manage

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import com.sgb.kjwl.AppActivity
import com.sgb.kjwl.R
import com.sgb.kjwl.databinding.ActivityWebsiteOfferListBinding
import com.sgb.kjwl.view.ui.fragment.manage.OtherInquiryFragment

/**
 * 缺省activity
 *
 */
class DefaultEmptyActivity : AppActivity() {


    private lateinit var mBinding : ActivityWebsiteOfferListBinding

    private var fragment : OtherInquiryFragment ?= null
    private var mTitle = ""

    companion object{
        const val KEY_TITLE = "key_title"
            fun launch(context: Context, title : String){
            val intent = Intent()
            intent.setClass(context, DefaultEmptyActivity::class.java)
            intent.putExtra(KEY_TITLE, title)
            context.startActivity(intent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_website_offer_list)
        if (intent != null){
            mTitle = intent.getStringExtra(KEY_TITLE)
        }
        if (savedInstanceState != null) {
            fragment = supportFragmentManager.findFragmentByTag(OtherInquiryFragment.TAG) as OtherInquiryFragment?
        } else {
            fragment = OtherInquiryFragment.newInstance("功能升级中")
            supportFragmentManager.beginTransaction().replace(R.id.container, fragment!!, OtherInquiryFragment.TAG).commit()
        }
        mBinding.include.ivBack.setOnClickListener { finish() }
        mBinding.include.titleView.text = mTitle
    }
}